package com.bt.lms.ui.page.teaching.plan;

import com.bt.lms.ui.action.teaching.plan.LEditTeachingPlanCancelBtnAction;
import com.bt.lms.ui.action.teaching.plan.LEditTeachingPlanSaveBtnAction;
import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;

/**
 * 教学计划
 * 列表 编辑界面
 */
public class PageEditTeachingPlanBasicInfo extends VBox{


    /**
     * 标题宽
     */
    private Integer labelWidth = 200;
    /**
     * 宽
     */
    public Integer preWidth = 1040;


    public PageEditTeachingPlanBasicInfo(){


        //初始化所在位置
        initLocation();


        //需要编辑的教学计划名称
        HBox hBox = new HBox();
        Insets insets = new Insets(10);
        hBox.setPadding(insets);
        Label label = new Label("2023年java高级工程师教学计划");
        Font font = Font.font("仿宋", FontWeight.THIN, FontPosture.REGULAR,15);
        label.setFont(font);
        hBox.getChildren().add(label);
        this.getChildren().add(hBox);

        this.setPrefWidth(preWidth);

        //初始化编辑内容
        initBasicInfo();
        //初始化保存按钮
        initSaveButton();

    }

    /**
     * 初始化所在位置
     */
    public void initLocation(){

        HBox hBox = new HBox();
        Insets insets = new Insets(10);
        hBox.setPadding(insets);
        Label label = new Label("当前位置：🏠>教学管理>教学计划>编辑");
        Font font = Font.font("仿宋", FontWeight.THIN, FontPosture.REGULAR,18);
        label.setFont(font);
        hBox.getChildren().add(label);
        this.getChildren().add(hBox);

    }

    /**
     * 初始化编辑内容
     */
    public void initBasicInfo(){

        //基本信息主盒子
        VBox vBox = new VBox();
        Insets insets = new Insets(10);
        vBox.setPadding(insets);
        vBox.setSpacing(10);
        //计划编号
        HBox codeHBox = new HBox();
        codeHBox.setSpacing(10);
        Label codeLabel = new Label("计划编号");
        codeLabel.setPrefWidth(labelWidth);
        TextField codeTF = new TextField("15615156");
        codeTF.setId("codeTF");
        ObservableList<Node> teachingPlanSerialNumberHBoxChildren = codeHBox.getChildren();
        teachingPlanSerialNumberHBoxChildren.addAll(codeLabel,codeTF);
        //教学计划名称
        HBox nameHBox = new HBox();
        nameHBox.setSpacing(10);
        Label nameLabel = new Label("教学计划名称");
        nameLabel.setPrefWidth(labelWidth);
        TextField nameTF = new TextField("2023年java高级工程师教学计划");
        nameTF.setId("nameTF");
        ObservableList<Node> teachingPlanSerialNameHBoxChildren = nameHBox.getChildren();
        teachingPlanSerialNameHBoxChildren.addAll(nameLabel,nameTF);
        //所属的学习中心
        HBox belongToCollegeHBox = new HBox();
        belongToCollegeHBox.setSpacing(10);
        Label belongToCollegeLabel = new Label("所属的学习中心");
        belongToCollegeLabel.setPrefWidth(labelWidth);
        ComboBox<String> belongToCollegeComboBox = new ComboBox<>();
        belongToCollegeComboBox.setCursor(Cursor.HAND);
        belongToCollegeComboBox.setId("belToCollegeCB");
        belongToCollegeComboBox.getSelectionModel().select("清华大学");
        belongToCollegeComboBox.getItems().add("清华大学");
        belongToCollegeComboBox.getItems().add("师范大学");
        belongToCollegeComboBox.getItems().add("北京大学");
        ObservableList<Node> belongToCollegeHBoxChildren = belongToCollegeHBox.getChildren();
        belongToCollegeHBoxChildren.addAll(belongToCollegeLabel,belongToCollegeComboBox);
        //所属专业
        HBox belongToMajorHBox = new HBox();
        belongToMajorHBox.setSpacing(10);
        Label belongToMajorLabel = new Label("所属专业");
        belongToMajorLabel.setPrefWidth(labelWidth);
        ComboBox<String> belongToMajorComboBox = new ComboBox<>();
        belongToMajorComboBox.setCursor(Cursor.HAND);
        belongToMajorComboBox.setId("belongToMajor");
        belongToMajorComboBox.getSelectionModel().select("java");
        belongToMajorComboBox.getItems().add("java");
        belongToMajorComboBox.getItems().add("c++");
        belongToMajorComboBox.getItems().add("c");
        ObservableList<Node> belongToMajorHBoxChildren = belongToMajorHBox.getChildren();
        belongToMajorHBoxChildren.addAll(belongToMajorLabel,belongToMajorComboBox);
        //适合层次
        HBox applyLevelHBox = new HBox();
        applyLevelHBox.setSpacing(10);
        Label applyLevelLabel = new Label("适合层次");
        applyLevelLabel.setPrefWidth(labelWidth);
        ComboBox<String> applyLevelComboBox = new ComboBox<>();
        applyLevelComboBox.setCursor(Cursor.HAND);
        applyLevelComboBox.setId("applyCB");
        applyLevelComboBox.getSelectionModel().select("免费师范生");
        applyLevelComboBox.getItems().add("免费师范生");
        applyLevelComboBox.getItems().add("免费师范硕士");
        applyLevelComboBox.getItems().add("其他");
        ObservableList<Node> applyLevelHBoxChildren = applyLevelHBox.getChildren();
        applyLevelHBoxChildren.addAll(applyLevelLabel,applyLevelComboBox);
        //学制
        HBox lengthOfSchoolingHBox = new HBox();
        lengthOfSchoolingHBox.setSpacing(10);
        Label lengthOfSchoolingLabel = new Label("学制");
        lengthOfSchoolingLabel.setPrefWidth(labelWidth);
        TextField lengthOfSchoolingTF = new TextField("4");
        lengthOfSchoolingTF.setId("lengthOfSchoolingTF");
        ComboBox<String> lengthOfSchoolingComboBox = new ComboBox<>();
        lengthOfSchoolingComboBox.setCursor(Cursor.HAND);
        lengthOfSchoolingComboBox.setId("lengthOfSchoolingCB");
        lengthOfSchoolingComboBox.getSelectionModel().select("年");
        lengthOfSchoolingComboBox.getItems().add("年");
        lengthOfSchoolingComboBox.getItems().add("月");
        lengthOfSchoolingComboBox.getItems().add("学时");
        ObservableList<Node> lengthOfSchoolingHBoxChildren = lengthOfSchoolingHBox.getChildren();
        lengthOfSchoolingHBoxChildren.addAll(lengthOfSchoolingLabel,lengthOfSchoolingTF,lengthOfSchoolingComboBox);
        //可重修次数
        HBox numberOfRepairableTimesHBox = new HBox();
        numberOfRepairableTimesHBox.setSpacing(10);
        Label numberOfRepairableTimesLabel = new Label("可重修次数");
        numberOfRepairableTimesLabel.setPrefWidth(labelWidth);
        TextField numberOfRepairableTimesTF = new TextField("5年");
        numberOfRepairableTimesTF.setId("numberOfRepairableTimesTF");
        ObservableList<Node> periodOfSchoolingHBoxChildren = numberOfRepairableTimesHBox.getChildren();
        periodOfSchoolingHBoxChildren.addAll(numberOfRepairableTimesLabel,numberOfRepairableTimesTF);

        //小盒子放大盒子里
        ObservableList<Node> children = vBox.getChildren();
        children.addAll(codeHBox,nameHBox,belongToCollegeHBox,belongToMajorHBox,
                applyLevelHBox,lengthOfSchoolingHBox,numberOfRepairableTimesHBox);

        this.getChildren().add(vBox);

    }

    /**
     * 初始化保存按钮
     */
    public void initSaveButton(){

        //按钮小盒子
        HBox hBox = new HBox();
        hBox.setSpacing(10);
        hBox.setAlignment(Pos.CENTER);


        Button saveBtn = new Button("保存并返回");
        saveBtn.setCursor(Cursor.HAND);
        BtnStyle.saveBtn(saveBtn);
        LEditTeachingPlanSaveBtnAction editTeachingPlanSaveBtnAction = new LEditTeachingPlanSaveBtnAction(this);
        saveBtn.setOnAction(editTeachingPlanSaveBtnAction);
        Button cancelBtn = new Button("取消");
        cancelBtn.setCursor(Cursor.HAND);
        BtnStyle.cancelBtn(cancelBtn);
        LEditTeachingPlanCancelBtnAction editTeachingPlanCancelBtnAction = new LEditTeachingPlanCancelBtnAction();
        cancelBtn.setOnAction(editTeachingPlanCancelBtnAction);

        //放入按钮盒子
        hBox.getChildren().addAll(saveBtn,cancelBtn);

        //放入大盒子
        this.getChildren().add(hBox);

    }


}
